
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@include file="../Head.jsp"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<div class="Body" style="background: url(${ctx}/resource/img/big/banner1.jpg) center;">
	<div class="baseWidth block">
		<div class="clear block h15"></div>
		<div class="login-model   ml20 fr  block radius5" style="background-color: white;">
			<div style="z-index: 10; margin: 10px;">
				<div class="login-title">
					<a href="${ctx}/login.html">立即登录&gt</a>
					<h2>
						<img src="${ctx}/resource/img/reg.png" />
					</h2>
				</div>
				<div class="login-content block fl">
					<p class="error" id="common_errors"><span></span>&nbsp;</p>
					<legend>注册信息</legend>
					<form id="regist_form" method="post" action="${ctx}/register/RegisterAction.html" onsubmit="return checkRegister(this)"> 
						<ul>
							<li id="reg-name"><span class="tip">手机号/邮箱</span> <input type="text" name="login_name" tabindex="1"  /></li>
							<li id="reg-pass"><span class="tip">请输入密码</span> <input tabindex="2" type="password" name="password" />
								<ul class="password-level">
									<li id="strength_L">低</li>
									<li id="strength_M">中</li>
									<li id="strength_H">高</li>
								</ul></li>
							<li><span class="tip">请再次输入密码</span> <input tabindex="3" type="password" name="rePassword" /></li>
							<li ><span class="tip">请输入验证码</span> <input tabindex="3" type="text" name="validate" style="width: 40%" />
								<img  class="validateImg fr" onclick="getValidateImg(this)"/>
							</li>
							<li class="agreement"><em><input type="checkbox" checked="true"></em> <a href="#" >《支付之家会员注册协议》</a></li>
							<li><input type="submit" class="md_basic_btn"  value="同意协议并注册" /> </li>
						</ul>
					</form>
				</div>
			</div>
		</div>
		<div class="clear h15"></div>
	</div>
</div>
<script type="text/javascript">
	var login_name_ck=true;
	$(function(){
		getValidateImg($(".validateImg")[0]);
		//=================
		$("input[name=password]").keyup(function(){
			var val=$(this).val();
			var level=SecurityLevel($(this).val());
			$(".password-level li").css({"background":"#eee","color":"black"});
			if(val.length>0 && val.length<8)
				level="弱";
			if(level=="弱"){
				$("#strength_L").css({"background":"#D51629","color":"white"});
			}if(level=="中"){
				$("#strength_L").css({"background":"#FCB815","color":"white"});
				$("#strength_M").css({"background":"#FCB815","color":"white"});
			}if(level=="强"){
				$(".password-level li").css({"background":"#01BAF2","color":"white"});
			}
		});
		$("input[name=login_name]").blur(function() {
			var val = $(this).val();
			chenckLoginName(val);
		});
	});
	function chenckLoginName(loginName){
		if(loginName.length>0)
		sendRequestTB("${ctx}/register/ajaxCheckName.html", {
			name : loginName
		}, function(obj) {
			/* var obj = jQuery.parseJSON(data); */
			if(obj.retCode!=1){
				setError(obj.retMsg,this);
				login_name_ck=false;
			}else{
				setError("",this);
				login_name_ck=true;
			}
		});
	}
	function checkRegister(form){
		var login_name=$("#regist_form input[name=login_name]").val();
		var password=$("#regist_form input[name=password]").val();
		var rePassword=$("#regist_form input[name=rePassword]").val();
		//=====
		if(login_name=="" )
			return setError("请输入帐号！","input[name=login_name]");
		if(!(isEmail(login_name) || isMobile(login_name)))
			return setError("请输入合理的帐号[手机号或邮箱]！","input[name=login_name]"); 
		chenckLoginName(login_name);
		if(!login_name_ck)
			return setError("当前用户已经存在 ！","input[name=login_name]");
		//=====
		if(password=="" )
			return setError("请输入密码！","input[name=password]");
		if(password.length<8 || password.length>24)
			return setError("密码长度在 8 ~ 24 位之间！","input[name=password]"); 
		if(password!=rePassword || rePassword=="")
			return setError("两次输入的密码不一致！","input[name=rePassword]");
		baseCheckForm(form);
		return true;
	}
	function setError(str,obj){
		$(".error span").text(str);
		if(obj!=null || obj!="") 
			$(obj).focus();
		return false;
	}
	
</script>
<%@include file="../Bottom.jsp"%>
